/**
 * 系统接口
 */
import request from '@/utils/request';
import qs from 'qs';

// 贾林一键登录接口
export function authApi(params) {
    return request({
        url: '/api/bas-auth/oauth/token' + '?' + qs.stringify(params, { indices: false }),
        method: 'get',
    })
}
// 用户名密码登录
export function loginByUsername(data) {
    return request({
        url: '/api/bas-auth/oauth/token',
        method: 'post',
        headers: {
            'Tenant-Id': data.tenantId,
        },
        params: {
            tenantId: data.tenantId,
            username: data.username,
            password: data.password,
            scope: "all",
            type: data.type,
            grant_type: "password",
        }
    })
}
// 刷新token
export function refreshToken(refresh_token, tenantId) {
    return request({
        url: '/api/bas-auth/oauth/token',
        method: 'post',
        headers: {
            'Tenant-Id': tenantId
        },
        params: {
            tenantId,
            refresh_token,
            grant_type: "refresh_token",
            scope: "all",
        }
    })
}
// 退出登录
export function logout() {
    return request({
        url: '/api/bas-auth/oauth/logout',
        method: 'get',
    })
}
// 获取验证码
export function getCaptcha() {
    return request({
        url: '/api/bas-auth/oauth/captcha',
        method: 'get',
    })
}
// 获取用户信息
export function getUserInfo() {
    return request({
        url: '/api/bas-auth/oauth/user-info',
        method: 'get',
    })
}
// 获取菜单权限按钮
export function getButtons() {
    return request({
        url: '/api/bas-system/menu/buttons',
        method: 'get',
    })
}
// 清除缓存
export function clearCache() {
    return request({
        url: '/api/bas-auth/oauth/clear-cache',
        method: 'get',
    })
}
// 获取各个系统菜单列表(之前的portal页首页系统列表)
export function getPortalList() {
    return request({
        url: '/api/bas-system/home-page/get-system-list',
        method: 'get',
    })
}
// 获取菜单列表
export function getMenuList(current, size, params) {
    return request({
        url: '/api/bas-system/menu/list',
        method: 'get',
        params: {
            ...params,
            current,
            size,
        }
    })
}

